﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using System.Windows.Forms;

namespace 作业4
{
    public partial class Form1 : Form
    {
        int isTick;//表示trik次数
        static int isAlarm;//表示alarm次数
        public Form1()
        {
            InitializeComponent();
            isTick = 0;
            isAlarm = 0;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                this.label2.Text = "响铃!";
                
            }
            catch (Exception e1)
            {

                this.label2.Text = "发生错误!"+e1.Message;
            }
        }

        private void Alarm(object sender, ElapsedEventArgs e)
        {
            try
            {
                isAlarm++;
                this.label1.Text = DateTime.Now.ToString("HH时mm分ss秒");
                if (isAlarm % 3 == 0) this.label2.Text = "";
            }
            catch (Exception e2)
            {

                Console.WriteLine("发生错误"+e2.Message);
            }
        }

       

        private void Tick(object sender, EventArgs e)
        {
            try
            {
                isTick++;
                if (isTick % 2 == 0) { this.label4.Text = "嘀嗒"; }
                else this.label4.Text = "";


            }
            catch (Exception e3)
            {

                this.label2.Text = "发生错误!" + e3.Message;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }
    }
}